package com.tongji.housediy.view
{
	import com.tongji.housediy.events.commonEvent.ChangeData3D;
	import com.tongji.housediy.events.commonEvent.SetCompStateEvent;
	
	import flash.events.MouseEvent;
	
	import org.robotlegs.mvcs.Mediator;

	/**
	 * 
	 * @author xuxunjia
	 * 
	 */	
	public class SixViewsCompMediator extends Mediator
	{
		[Inject]
		public var view:SixViewsComp;
		
		override public function onRegister():void
		{
			view.ToDownBtn.addEventListener(MouseEvent.CLICK, downBtnClickHandler);
			view.ToFrontBtn.addEventListener(MouseEvent.CLICK, frontBtnClickHandler);
			view.ToBackBtn.addEventListener(MouseEvent.CLICK, backBtnClickHandler);
			view.ToLeftBtn.addEventListener(MouseEvent.CLICK, leftBtnClickHandler);
			view.ToRightBtn.addEventListener(MouseEvent.CLICK, rightBtnClickHandler);
		}
		
		private function downBtnClickHandler(event:MouseEvent):void
		{
			dispatch(new ChangeData3D(ChangeData3D.DOWN_VIEW));
			
			// 设置 3D 按钮的 enabled 属性，通过其绑定属性
			dispatch(new SetCompStateEvent(SetCompStateEvent.SET_COMP_NORMAL_STATE));
		}
		
		private function frontBtnClickHandler(event:MouseEvent):void
		{
			dispatch(new ChangeData3D(ChangeData3D.FRONT_VIEW));
			
			// 设置 3D 按钮的 enabled 属性，通过其绑定属性
			dispatch(new SetCompStateEvent(SetCompStateEvent.SET_COMP_NORMAL_STATE));
		}
		
		private function backBtnClickHandler(event:MouseEvent):void
		{
			dispatch(new ChangeData3D(ChangeData3D.BACK_VIEW));
			
			// 设置 3D 按钮的 enabled 属性，通过其绑定属性
			dispatch(new SetCompStateEvent(SetCompStateEvent.SET_COMP_NORMAL_STATE));
		}
		
		private function leftBtnClickHandler(event:MouseEvent):void
		{
			dispatch(new ChangeData3D(ChangeData3D.LEFT_VIEW));
			
			// 设置 3D 按钮的 enabled 属性，通过其绑定属性
			dispatch(new SetCompStateEvent(SetCompStateEvent.SET_COMP_NORMAL_STATE));
		}
		
		private function rightBtnClickHandler(event:MouseEvent):void
		{
			dispatch(new ChangeData3D(ChangeData3D.RIGHT_VIEW));
			
			// 设置 3D 按钮的 enabled 属性，通过其绑定属性
			dispatch(new SetCompStateEvent(SetCompStateEvent.SET_COMP_NORMAL_STATE));
		}
	}
}